<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加图书</title>
</head>
<head th:replace="fragments/header :: head"></head>
<body>
<div th:replace="fragments/header :: navbar"></div>
<div class=" pt-5">
    <h3 class="text-center">新增图书</h3>
    <div class="row justify-content-center">
        <div class="col-6">
            <div class="alert alert-success" th:if="${successMessage}"
                 th:utext="${successMessage}">
            </div>
            <form name="bookForm" role="form" method="post" th:object="${bookForm}"
                  th:action="@{/books/add}" enctype="multipart/form-data">
                <div class="form-group">
                    <input type="hidden" class="form-control" id="id"
                           name="id" th:field="*{bookId}"/>
                </div>
                <div class="form-group">
                    <label class="form-control-label" for="field_bookname">图书名称</label>
                    <input type="text" class="form-control" name="bookName"
                           id="field_bookname" required th:field="*{bookName}"/>
                </div>
                <div class="form-group">
                    <label class="form-control-label" for="field_author">图书作者</label>
                    <input type="text" class="form-control" name="bookAuthor"
                           id="field_author" required th:field="*{bookAuthor}"/>
                </div>
                <div class="form-group">
                    <label class="form-control-label" for="field_publisher">出版社</label>
                    <input type="text" class="form-control" name="bookPublisher"
                           id="field_publisher" required th:field="*{bookPublisher}"/>
                </div>

                <div class="form-group">
                    <label class="form-control-label" for="field_isbn">图书ISBN</label>
                    <input type="text" class="form-control" name="bookIsbn"
                           id="field_isbn" required th:field="*{bookIsbn}"/>
                </div>

                <div class="form-group">
                    <label class="form-control-label" for="field_price">图书价格</label>
                    <input type="number" step="0.1" class="form-control" name="bookPrice"
                        id="field_price" required th:field="*{bookPrice}"/>
                </div>
                <div class="form-group">
                    <label class="form-control-label" for="field_description">图书简介</label>
                    <textarea class="form-control" name="bookDescription"
                              id="field_description" required th:field="*{bookDescription}"></textarea>
                </div>

                <div class="form-group">
                    <label class="form-control-label" for="field_image">Book Image</label>
                    <img  th:if="${edit}" height="100px"
                         th:src="@{|/bookImage?bookId=${bookForm.bookId}|}"/>
                    <input type="file" class="form-control" name="bookImage" id= "field_image"
                           th:field="*{bookImage}" accept="image/*"/>
                </div>


                <div class="col-12 text-right" >
                    <a type="button" class="btn btn-secondary" th:href="@{/books}">返回</a>
                    <button type="submit" class="btn btn-primary">新增</button>
                </div>
            </form>
        </div>
    </div>
</div>

</body>
</html>